import Vue from "vue";
import VueRouter from "vue-router";
import routes from "./routes";
import NProgress from "nprogress";
import "nprogress/nprogress.css";

Vue.use(VueRouter);

const router = new VueRouter({
  mode: "history",
  routes,
});

//进度条的配置
//使用全局前置守卫配置开启进度条
router.beforeEach((to, from, next) => {
  NProgress.start();

  next();
});

//使用全局后置钩子配置关闭进度条
router.afterEach(() => {
  NProgress.done();
});

export default router;
